import 'package:flutter/material.dart';

class MyApp13 extends StatelessWidget {
  const MyApp13({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
        home: Scaffold(
            appBar: AppBar(
              title: const Text('GridtView'),
              backgroundColor: Colors.black26,
              centerTitle: true,
            ),
            body: GridView(
              // 固定个数，改变宽度
              // gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
              // 固定宽度，改变个数
              gridDelegate: const SliverGridDelegateWithMaxCrossAxisExtent(
                  // 固定侧轴元素个数 ===== 固定个数，改变宽度
                  // crossAxisCount: 3,
                  // =====================固定宽度，改变个数
                  maxCrossAxisExtent: 200,
                  mainAxisSpacing: 10,
                  crossAxisSpacing: 10),
              children: [
                Container(color: Colors.green, child: const Text('1')),
                Container(
                    color: const Color.fromARGB(255, 91, 76, 175),
                    child: const Text('2')),
                Container(color: Colors.green, child: const Text('3')),
                Container(
                    color: const Color.fromARGB(255, 125, 175, 76),
                    child: const Text('4')),
                Container(
                    color: const Color.fromARGB(255, 175, 76, 129),
                    child: const Text('5')),
              ],
            )));
  }
}
